import emitter from '@/render/utils/mitt'

interface IMenuItem {
  label: string
  click: () => void
}
interface IMenuSperator {
  type: 'separator'
}

export type IMenuTemplate = IMenuItem | IMenuSperator

export const contentMenuRemoveItem: IMenuTemplate = {
  label: '删除',
  click: () => {
    emitter.emit('remove', 'emitter')
  }
}

export const modelMenuConfig: IMenuTemplate[] = [
  {
    label: '添加下一级',
    click: (): void => {
      emitter.emit('appendNextContainer', 'emitter')
    }
  },
  { type: 'separator' }
]

export const containerMenuConfig: IMenuTemplate[] = [
  {
    label: '添加下一级(子容器)',
    click: (): void => {
      emitter.emit('appendNextSubContainer', 'emitter')
    }
  },
  {
    label: '添加下一级(参数)',
    click: (): void => {
      emitter.emit('appendNextParameter', 'emitter')
    }
  },
  {
    label: '添加下一级(引用)',
    click: (): void => {
      emitter.emit('appendNextReference', 'emitter')
    }
  },
  { type: 'separator' },
  {
    label: '添加同级',
    click: (): void => {
      emitter.emit('appendContainer', 'emitter')
    }
  }
]

export const parameterMenuConfig: IMenuTemplate[] = [
  {
    label: '添加同级',
    click: (): void => {
      emitter.emit('appendParameter', 'emitter')
    }
  }
]

export const parameterMenuConfig_boolean: IMenuTemplate[] = [
  {
    label: '添加配置参数',
    click: (): void => {
      emitter.emit('addApiConfigDef', 'emitter')
    }
  },
  {
    label: '添加同级',
    click: (): void => {
      emitter.emit('appendParameter', 'emitter')
    }
  }
]

export const parameterMenuConfig_enum: IMenuTemplate[] = [
  {
    label: '添加下一级(枚举)',
    click: (): void => {
      emitter.emit('appendNextLitiral', 'emitter')
    }
  },
  {
    label: '添加同级',
    click: (): void => {
      emitter.emit('appendParameter', 'emitter')
    }
  }
]

export const referenceMenuConfig: IMenuTemplate[] = [
  {
    label: '添加下一级(被引用对象)',
    click: (): void => {
      emitter.emit('appendNextDestination', 'emitter')
      // this.handleCommand('appendNextDestination', data)
    }
  }
]

export const referenceMenuConfig_choice: IMenuTemplate[] = [
  {
    label: '添加下一级(被引用对象)',
    click: (): void => {
      emitter.emit('appendNextDestination', 'emitter')
      // this.handleCommand('appendNextDestination', data)
    }
  },
  {
    label: '添加同级',
    click: (): void => {
      emitter.emit('appendReference', 'emitter')
    }
  }
]

export const literalMenuConfig: IMenuTemplate[] = [
  {
    label: '添加配置参数',
    click: (): void => {
      emitter.emit('addOtherConfigDef', 'emitter')
    }
  },
  {
    label: '添加同级',
    click: (): void => {
      emitter.emit('appendLiteral', 'emitter')
    }
  }
]
